package cn.ffcs.uec.staffAndOutStaff.dao.impl;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import cn.ffcs.uec.common.util.PermissionUtil;
import cn.ffcs.uec.staffAndOutStaff.dao.OutStaffImportListDao;
import cn.ffcs.uec.staffAndOutStaff.vo.OutStaffContractInfo;
import cn.ffcs.uec.staffAndOutStaff.vo.OutStaffDropOutListVo;
import cn.ffcs.uec.staffAndOutStaff.vo.OutStaffImportListVo;
import cn.ffcs.uec.staffAndOutStaff.vo.OutStaffSalaryDetail;
import cn.ffcs.uec.staffAndOutStaff.vo.OutStaffTraMsg;
import cn.ffcs.uec.staffAndOutStaff.vo.OutStaffVocQua;
import cn.ffcs.uom.common.dao.BaseDaoImpl;
import cn.ffcs.uom.common.util.StrUtil;
import cn.ffcs.uom.common.vo.PageInfo;

@Repository("outStaffImportListDao")
@Transactional
public class OutStaffImportListDaoImpl extends BaseDaoImpl implements OutStaffImportListDao {

    @Override
    public PageInfo queryPageInfoByOutStaffImportListVo(OutStaffImportListVo outStaffImportListVo, int current,
            int pageSize) {
        String orgName = PermissionUtil.getManagerOrg();
        StringBuilder sb = new StringBuilder(" SELECT * FROM VIEW_OUTSTAFF_IMPORT_LIST T WHERE 1 = 1 ");
        List<Object> params = new ArrayList<Object>();
        if (null != outStaffImportListVo) {
            if (!StrUtil.isNullOrEmpty(outStaffImportListVo.getPsnName())) {
                sb.append(" AND T.psnName like ? ");
                params.add("%" + StringEscapeUtils.escapeSql(outStaffImportListVo.getPsnName()) + "%");
            }
            if (!StrUtil.isNullOrEmpty(outStaffImportListVo.getPsnCode())) {
                sb.append(" AND T.psnCode = ? ");
                params.add(outStaffImportListVo.getPsnCode());
            }
            if (!StrUtil.isNullOrEmpty(outStaffImportListVo.getPkOrg())) {
                sb.append(" AND T.pkOrg = ? ");
                params.add(outStaffImportListVo.getPkOrg());
            }
            if (!StrUtil.isNullOrEmpty(outStaffImportListVo.getPkDept())) {
                sb.append(" AND T.pkDept = ? ");
                params.add(outStaffImportListVo.getPkDept());
            }
        }
        if (!"区本部".equals(orgName)) {
            sb.append(" AND T.orgName LIKE ? ");
            params.add("%" + StringEscapeUtils.escapeSql(orgName) + "%");
        }
        return this.jdbcFindPageInfo(sb.toString(), params, current, pageSize, OutStaffImportListVo.class);
    }

    @Override
    public List<Map<String, Object>> getOutStaffImportListVoData(OutStaffImportListVo outStaffImportListVo) {
        String orgName = PermissionUtil.getManagerOrg();
        List<Object> params = new ArrayList<Object>();
        StringBuffer sb = new StringBuffer();
        sb.append(" SELECT t.Psnname 姓名,t.Idnum 身份证号码,t.sex 性别,t.Birthdate 出生日期, "
                + " t.higEdu 最高学历,t.ftEdu 全日制学历,t.Degree 学位,t.orgCode 公司编码, "
                + " t.orgName 业务管理公司,t.deptCode 部门编码,t.deptName 业务管理部门, "
                + " t.isCEO 是否小CEO,t.orgMemo 机构备注,t.basePost 基准岗位, "
                + " t.postName 岗位名称,t.begindate 在本单位从事外包开始日期, "
                + " t.outSourcingCode 外包公司编码,t.outSourcingName 所属外包公司, "
                + " t.contractCode 合同编码,t.outSourEmpCategory 外包公司用工类别, "
                + " t.enddate 退回外包公司日期,t.outSourBeginDate 开始日期, "
                + " t.outSourEndDate 结束日期,t.engInOutsourBusYears 从事电信外包业务年限, "
                + " t.memo 备注,t.uuid 统一目录UID,t.mobilePhone 移动电话,t.OFFICEPHONE 办公电话, "
                + " t.accountType 户口类型,t.nationality 民族,t.outsouclassify 外包人员分类, "
                + " t.mainEmil 主邮箱 FROM   VIEW_OUTSTAFF_IMPORT_LIST T WHERE 1 = 1  ");
        if(null != outStaffImportListVo) {
            if (!StrUtil.isNullOrEmpty(outStaffImportListVo.getPsnName())) {
                sb.append(" AND T.psnName like ? ");
                params.add("%" + StringEscapeUtils.escapeSql(outStaffImportListVo.getPsnName()) + "%");
            }
            if (!StrUtil.isNullOrEmpty(outStaffImportListVo.getPsnCode())) {
                sb.append(" AND T.psnCode = ? ");
                params.add(outStaffImportListVo.getPsnCode());
            }
            if (!StrUtil.isNullOrEmpty(outStaffImportListVo.getPkOrg())) {
                sb.append(" AND T.pkOrg = ? ");
                params.add(outStaffImportListVo.getPkOrg());
            }
            if (!StrUtil.isNullOrEmpty(outStaffImportListVo.getPkDept())) {
                sb.append(" AND T.pkDept = ? ");
                params.add(outStaffImportListVo.getPkDept());
            }
        }
        if (!"区本部".equals(orgName)) {
            sb.append(" AND T.orgName LIKE ? ");
            params.add("%" + StringEscapeUtils.escapeSql(orgName) + "%");
        }
        return this.getJdbcTemplate().queryForList(sb.toString(), params.toArray());
    }

    @Override
    public PageInfo queryPageInfoByOutStaffContractInfo(OutStaffContractInfo outStaffContractInfo, int current,
            int pageSize) {
        String orgName = PermissionUtil.getManagerOrg();
        StringBuilder sb = new StringBuilder(" SELECT * FROM VIEW_OUTSTAFF_CONTRACT_INFO T WHERE 1 = 1 ");
        List<Object> params = new ArrayList<Object>();
        if (null != outStaffContractInfo) {
            if (!StrUtil.isNullOrEmpty(outStaffContractInfo.getPsnName())) {
                sb.append(" AND T.psnName like ? ");
                params.add("%" + StringEscapeUtils.escapeSql(outStaffContractInfo.getPsnName()) + "%");
            }
            if (!StrUtil.isNullOrEmpty(outStaffContractInfo.getPsnCode())) {
                sb.append(" AND T.psnCode = ? ");
                params.add(outStaffContractInfo.getPsnCode());
            }
            if (!StrUtil.isNullOrEmpty(outStaffContractInfo.getPkOrg())) {
                sb.append(" AND T.pkOrg = ? ");
                params.add(outStaffContractInfo.getPkOrg());
            }
            if (!StrUtil.isNullOrEmpty(outStaffContractInfo.getPkDept())) {
                sb.append(" AND T.pkDept = ? ");
                params.add(outStaffContractInfo.getPkDept());
            }
        }
        if (!"区本部".equals(orgName)) {
            sb.append(" AND T.orgName LIKE ? ");
            params.add("%" + StringEscapeUtils.escapeSql(orgName) + "%");
        }
        return this.jdbcFindPageInfo(sb.toString(), params, current, pageSize, OutStaffContractInfo.class);
    }

    @Override
    public List<Map<String, Object>> getOutStaffContractInfoData(OutStaffContractInfo outStaffContractInfo) {
        String orgName = PermissionUtil.getManagerOrg();
        List<Object> params = new ArrayList<Object>();
        StringBuffer sb = new StringBuffer();
        sb.append(" SELECT T.Psnname 姓名,T.Idnum 身份证号码,T.contNum 合同编号, "
                + " T.contTermtype 合同期限类型,T.contBeginDate 合同开始日期, "
                + " T.contEndDate 合同结束日期,T.trialPeriod \"试用期限（月）\", "
                + " T.actualEndDate 实际终止日期,T.contChangeType 合同变动类型, "
                + " T.workhourSystem 工时制,T.contMajor 劳动合同主体,T.newMark 是否最新合同, "
                + " T.REMARK 备注,T.outSourCode 外包公司编码,T.contCode 合同编码  "
                + " FROM  VIEW_OUTSTAFF_CONTRACT_INFO T WHERE 1 = 1 ");
        if(null != outStaffContractInfo) {
            if (!StrUtil.isNullOrEmpty(outStaffContractInfo.getPsnName())) {
                sb.append(" AND T.psnName like ? ");
                params.add("%" + StringEscapeUtils.escapeSql(outStaffContractInfo.getPsnName()) + "%");
            }
            if (!StrUtil.isNullOrEmpty(outStaffContractInfo.getPsnCode())) {
                sb.append(" AND T.psnCode = ? ");
                params.add(outStaffContractInfo.getPsnCode());
            }
            if (!StrUtil.isNullOrEmpty(outStaffContractInfo.getPkOrg())) {
                sb.append(" AND T.pkOrg = ? ");
                params.add(outStaffContractInfo.getPkOrg());
            }
            if (!StrUtil.isNullOrEmpty(outStaffContractInfo.getPkDept())) {
                sb.append(" AND T.pkDept = ? ");
                params.add(outStaffContractInfo.getPkDept());
            }
        }
        if (!"区本部".equals(orgName)) {
            sb.append(" AND T.orgName LIKE ? ");
            params.add("%" + StringEscapeUtils.escapeSql(orgName) + "%");
        }
        return this.getJdbcTemplate().queryForList(sb.toString(), params.toArray());
    }

    @Override
    public PageInfo queryPageInfoByOutStaffDropOutListVo(OutStaffDropOutListVo outStaffDropOutListVo, int currentPage, int pageSize,
            Date beginDate, Date endDate) {
        String orgName = PermissionUtil.getManagerOrg();
        List<Object> params = new ArrayList<Object>();
        StringBuffer sb = new StringBuffer();
        // 格式化日期
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String beginDateStr = sdf.format(beginDate);
        String endDateStr = sdf.format(endDate);
        sb.append(" SELECT * FROM VIEW_OUTSTAFF_DROPOUT_LIST T WHERE 1 = 1  AND T.enddate BETWEEN ? AND ? ");
        params.add(beginDateStr);
        params.add(endDateStr);
        if(null != outStaffDropOutListVo) {
            if (!StrUtil.isNullOrEmpty(outStaffDropOutListVo.getPsnName())) {
                sb.append(" AND T.psnName like ? ");
                params.add("%" + StringEscapeUtils.escapeSql(outStaffDropOutListVo.getPsnName()) + "%");
            }
            if (!StrUtil.isNullOrEmpty(outStaffDropOutListVo.getPkOrg())) {
                sb.append(" AND T.pkOrg = ? ");
                params.add(outStaffDropOutListVo.getPkOrg());
            }
            if (!StrUtil.isNullOrEmpty(outStaffDropOutListVo.getPkDept())) {
                sb.append(" AND T.pkDept = ? ");
                params.add(outStaffDropOutListVo.getPkDept());
            }
            if (!StrUtil.isNullOrEmpty(outStaffDropOutListVo.getDatasources())) {
                sb.append(" AND T.datasources = ? ");
                params.add(outStaffDropOutListVo.getDatasources());
            }
            if (!StrUtil.isNullOrEmpty(outStaffDropOutListVo.getPsnStatus())) {
                sb.append(" AND T.psnStatus = ? ");
                params.add(outStaffDropOutListVo.getPsnStatus());
            }
            if (!StrUtil.isNullOrEmpty(outStaffDropOutListVo.getPsnType())) {
                sb.append(" AND T.psnType = ? ");
                params.add(outStaffDropOutListVo.getPsnType());
            }
        }
        if (!"区本部".equals(orgName)) {
            sb.append(" AND T.orgName LIKE ? ");
            params.add("%" + StringEscapeUtils.escapeSql(orgName) + "%");
        }
        return this.jdbcFindPageInfo(sb.toString(), params, currentPage, pageSize, OutStaffDropOutListVo.class);
    }

    @Override
    public List<Map<String, Object>> getOutStaffOutStaffDropOutListVoDate(OutStaffDropOutListVo outStaffDropOutListVo,Date beginDate, Date endDate) {
        String orgName = PermissionUtil.getManagerOrg();
        List<Object> params = new ArrayList<Object>();
        StringBuffer sb = new StringBuffer();
        // 格式化日期
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String beginDateStr = sdf.format(beginDate);
        String endDateStr = sdf.format(endDate);
        sb.append(" SELECT T.Psnname 姓名,T.Idnum 身份证号码,T.enddate 退回外包公司日期, "
                + " T.outSourCode 外包公司编码,T.ctCode  供应商合同编码 "
                + " FROM   VIEW_OUTSTAFF_DROPOUT_LIST T WHERE 1 = 1 AND T.enddate BETWEEN ? AND ? " );
        params.add(beginDateStr);
        params.add(endDateStr);
        if(null != outStaffDropOutListVo) {
            if (!StrUtil.isNullOrEmpty(outStaffDropOutListVo.getPsnName())) {
                sb.append(" AND T.psnName like ? ");
                params.add("%" + StringEscapeUtils.escapeSql(outStaffDropOutListVo.getPsnName()) + "%");
            }
            if (!StrUtil.isNullOrEmpty(outStaffDropOutListVo.getPkOrg())) {
                sb.append(" AND T.pkOrg = ? ");
                params.add(outStaffDropOutListVo.getPkOrg());
            }
            if (!StrUtil.isNullOrEmpty(outStaffDropOutListVo.getPkDept())) {
                sb.append(" AND T.pkDept = ? ");
                params.add(outStaffDropOutListVo.getPkDept());
            }
            if (!StrUtil.isNullOrEmpty(outStaffDropOutListVo.getDatasources())) {
                sb.append(" AND T.datasources = ? ");
                params.add(outStaffDropOutListVo.getDatasources());
            }
            if (!StrUtil.isNullOrEmpty(outStaffDropOutListVo.getPsnStatus())) {
                sb.append(" AND T.psnStatus = ? ");
                params.add(outStaffDropOutListVo.getPsnStatus());
            }
            if (!StrUtil.isNullOrEmpty(outStaffDropOutListVo.getPsnType())) {
                sb.append(" AND T.psnType = ? ");
                params.add(outStaffDropOutListVo.getPsnType());
            }
        }
        if (!"区本部".equals(orgName)) {
            sb.append(" AND T.orgName LIKE ? ");
            params.add("%" + StringEscapeUtils.escapeSql(orgName) + "%");
        }
        return this.getJdbcTemplate().queryForList(sb.toString(), params.toArray());
    }

    @Override
    public PageInfo queryPageInfoByOutStaffVocQua(OutStaffVocQua outStaffVocQua, int current, int pageSize) {
        String orgName = PermissionUtil.getManagerOrg();
        StringBuilder sb = new StringBuilder(" SELECT * FROM VIEW_OUTSTAFF_VOCQUA_LIST T WHERE 1 = 1 ");
        List<Object> params = new ArrayList<Object>();
        if (null != outStaffVocQua) {
            if (!StrUtil.isNullOrEmpty(outStaffVocQua.getPsnName())) {
                sb.append(" AND T.psnName like ? ");
                params.add("%" + StringEscapeUtils.escapeSql(outStaffVocQua.getPsnName()) + "%");
            }
            if (!StrUtil.isNullOrEmpty(outStaffVocQua.getPsnCode())) {
                sb.append(" AND T.psnCode = ? ");
                params.add(outStaffVocQua.getPsnCode());
            }
            if (!StrUtil.isNullOrEmpty(outStaffVocQua.getPkOrg())) {
                sb.append(" AND T.pkOrg = ? ");
                params.add(outStaffVocQua.getPkOrg());
            }
            if (!StrUtil.isNullOrEmpty(outStaffVocQua.getPkDept())) {
                sb.append(" AND T.pkDept = ? ");
                params.add(outStaffVocQua.getPkDept());
            }
        }
        if (!"区本部".equals(orgName)) {
            sb.append(" AND T.orgName LIKE ? ");
            params.add("%" + StringEscapeUtils.escapeSql(orgName) + "%");
        }
        return this.jdbcFindPageInfo(sb.toString(), params, current, pageSize, OutStaffVocQua.class);
    }

    @Override
    public List<Map<String, Object>> getOutStaffVocQuaData(OutStaffVocQua outStaffVocQua) {
        String orgName = PermissionUtil.getManagerOrg();
        List<Object> params = new ArrayList<Object>();
        StringBuffer sb = new StringBuffer();
        sb.append(" SELECT T.Psnname 姓名, T.IDNUM 身份证号码,T.qualitype 职业资格类别,T.qualiname 职业资格名称, "
                + " T.qualilevel 职业资格等级,T.getQualiDate 资格取得时间,T.basePostCode 基准岗位编码, "
                + " T.basePostName 基准岗位名称,T.CERTUNIT 发证单位,T.CERTCODE 证书编号,T.qualiEffPeriod 证书有效期, "
                + " T.theoreticalResults 理论考试成绩,T.practicalResults 实操考试成绩,T.finalResults 最终成绩, "
                + " T.highestLevelFlag 是否最高等级,T.REMARK 备注,T.outSourCode 外包公司编码, "
                + " T.ctCode 合同编码 FROM VIEW_OUTSTAFF_VOCQUA_LIST T WHERE 1 = 1");
        if(null != outStaffVocQua) {
            if (!StrUtil.isNullOrEmpty(outStaffVocQua.getPsnName())) {
                sb.append(" AND T.psnName like ? ");
                params.add("%" + StringEscapeUtils.escapeSql(outStaffVocQua.getPsnName()) + "%");
            }
            if (!StrUtil.isNullOrEmpty(outStaffVocQua.getPsnCode())) {
                sb.append(" AND T.psnCode = ? ");
                params.add(outStaffVocQua.getPsnCode());
            }
            if (!StrUtil.isNullOrEmpty(outStaffVocQua.getPkOrg())) {
                sb.append(" AND T.pkOrg = ? ");
                params.add(outStaffVocQua.getPkOrg());
            }
            if (!StrUtil.isNullOrEmpty(outStaffVocQua.getPkDept())) {
                sb.append(" AND T.pkDept = ? ");
                params.add(outStaffVocQua.getPkDept());
            }
        }
        if (!"区本部".equals(orgName)) {
            sb.append(" AND T.orgName LIKE ? ");
            params.add("%" + StringEscapeUtils.escapeSql(orgName) + "%");
        }
        return this.getJdbcTemplate().queryForList(sb.toString(), params.toArray());
    }

    @Override
    public PageInfo queryPageInfoByOutStaffTraMsg(OutStaffTraMsg outStaffTraMsg, int current, int pageSize) {
        String orgName = PermissionUtil.getManagerOrg();
        StringBuilder sb = new StringBuilder(" SELECT * FROM VIEW_OUTSTAFF_TRAMSG_LIST T WHERE 1 = 1 ");
        List<Object> params = new ArrayList<Object>();
        if (null != outStaffTraMsg) {
            if (!StrUtil.isNullOrEmpty(outStaffTraMsg.getPsnName())) {
                sb.append(" AND T.psnName like ? ");
                params.add("%" + StringEscapeUtils.escapeSql(outStaffTraMsg.getPsnName()) + "%");
            }
            if (!StrUtil.isNullOrEmpty(outStaffTraMsg.getPsnCode())) {
                sb.append(" AND T.psnCode = ? ");
                params.add(outStaffTraMsg.getPsnCode());
            }
            if (!StrUtil.isNullOrEmpty(outStaffTraMsg.getPkOrg())) {
                sb.append(" AND T.pkOrg = ? ");
                params.add(outStaffTraMsg.getPkOrg());
            }
            if (!StrUtil.isNullOrEmpty(outStaffTraMsg.getPkDept())) {
                sb.append(" AND T.pkDept = ? ");
                params.add(outStaffTraMsg.getPkDept());
            }
        }
        if (!"区本部".equals(orgName)) {
            sb.append(" AND T.orgName LIKE ? ");
            params.add("%" + StringEscapeUtils.escapeSql(orgName) + "%");
        }
        return this.jdbcFindPageInfo(sb.toString(), params, current, pageSize, OutStaffTraMsg.class);
    }

    @Override
    public List<Map<String, Object>> getOutStaffTraMsgData(OutStaffTraMsg outStaffTraMsg) {
        String orgName = PermissionUtil.getManagerOrg();
        List<Object> params = new ArrayList<Object>();
        StringBuffer sb = new StringBuffer();
        sb.append(" SELECT T.Psnname 姓名,T.IDNUM 身份证号码,T.traCode 培训活动编码,T.traName 培训活动名称, "
                + " T.BEGINDATE 培训开始时间,T.ENDDATE 培训结束时间,T.traClass 培训类别,T.traMode 培训方式, "
                + " T.traLocation 培训地点,T.traMethod 参训方式,T.traObjective 培训目标,T.traContent 培训内容,"
                + " T.traTime 培训学时,T.traResult 培训成绩,T.CERTNAME 证书名称,T.CERTUNIT 发证单位,T.CERTCODE 证书编号, "
                + " T.traValidity 有效期,T.traSignDate 获证日期,T.traHostUnit 主办单位,T.traCoOrganizer 协办单位, "
                + " T.traUndertakingUnit 承办单位,T.traLeaEvaluationResults 学习层评估成绩,T.traPerformanceResults 行为层评估成绩, "
                + " T.traCertificateLevel 证书等级,T.REMARK 备注,T.outSourCode 外包公司编码, "
                + " T.ctCode 合同编码 FROM  VIEW_OUTSTAFF_TRAMSG_LIST T WHERE 1 = 1 ");
        if (null != outStaffTraMsg) {
            if (!StrUtil.isNullOrEmpty(outStaffTraMsg.getPsnName())) {
                sb.append(" AND T.psnName like ? ");
                params.add("%" + StringEscapeUtils.escapeSql(outStaffTraMsg.getPsnName()) + "%");
            }
            if (!StrUtil.isNullOrEmpty(outStaffTraMsg.getPsnCode())) {
                sb.append(" AND T.psnCode = ? ");
                params.add(outStaffTraMsg.getPsnCode());
            }
            if (!StrUtil.isNullOrEmpty(outStaffTraMsg.getPkOrg())) {
                sb.append(" AND T.pkOrg = ? ");
                params.add(outStaffTraMsg.getPkOrg());
            }
            if (!StrUtil.isNullOrEmpty(outStaffTraMsg.getPkDept())) {
                sb.append(" AND T.pkDept = ? ");
                params.add(outStaffTraMsg.getPkDept());
            }
        }
        if (!"区本部".equals(orgName)) {
            sb.append(" AND T.orgName LIKE ? ");
            params.add("%" + StringEscapeUtils.escapeSql(orgName) + "%");
        }
        return this.getJdbcTemplate().queryForList(sb.toString(), params.toArray());
    }

    @Override
    public PageInfo queryPageInfoByOutStaffSalaryDetail(OutStaffSalaryDetail outStaffSalaryDetail, int current,
            int pageSize, String year, String month) {
        String orgName = PermissionUtil.getManagerOrg();
        StringBuilder sb = new StringBuilder(" SELECT * FROM  view_OutStaff_salaryDetail T WHERE 1 = 1 and T.year = ? and T.period = ? ");
        List<Object> params = new ArrayList<Object>();
        params.add(year);
        params.add(month);
        if (null != outStaffSalaryDetail) {
            if (!StrUtil.isNullOrEmpty(outStaffSalaryDetail.getPsnName())) {
                sb.append(" AND T.psnName like ? ");
                params.add("%" + StringEscapeUtils.escapeSql(outStaffSalaryDetail.getPsnName()) + "%");
            }
            if (!StrUtil.isNullOrEmpty(outStaffSalaryDetail.getPsnCode())) {
                sb.append(" AND T.psnCode = ? ");
                params.add(outStaffSalaryDetail.getPsnCode());
            }
            if (!StrUtil.isNullOrEmpty(outStaffSalaryDetail.getPkOrg())) {
                sb.append(" AND T.pkOrg = ? ");
                params.add(outStaffSalaryDetail.getPkOrg());
            }
            if (!StrUtil.isNullOrEmpty(outStaffSalaryDetail.getPkDept())) {
                sb.append(" AND T.pkDept = ? ");
                params.add(outStaffSalaryDetail.getPkDept());
            }
        }
        if (!"区本部".equals(orgName)) {
            sb.append(" AND T.orgName LIKE ? ");
            params.add("%" + StringEscapeUtils.escapeSql(orgName) + "%");
        }
        return this.jdbcFindPageInfo(sb.toString(), params, current, pageSize, OutStaffSalaryDetail.class);
    }

    @Override
    public List<Map<String, Object>> getOutStaffSalaryDetailData(OutStaffSalaryDetail outStaffSalaryDetail, String year, String month) {
        String orgName = PermissionUtil.getManagerOrg();
        List<Object> params = new ArrayList<Object>();
        StringBuffer sb = new StringBuffer();
        sb.append(" SELECT T.psnName 人员姓名,T.psnCode 人员编码,T.idNum 身份证,T.year 年度,T.period 期间,T.unitId 单位编码,T.unitName 单位名称,  "
                + " T.salaryIncome 外包人员薪酬收入,T.insuFundFee 外包人员保险公积金费用, T.personOtherFee \"外包人员其他费用（个人）\",    "
                + " T.companyOtherFee \"外包其他费用（公司分摊）\", T.pension 外包人员养老保险, T.mediInsurance  外包人员医疗保险,  "
                + " T.unempInsurance 外包人员失业保险, T.injuryInsurance 外包人员工伤保险 , T.mateInsurance  外包人员生育保险, T.providentFund 外包人员公积金,  "
                + " T.otherInsurance 其他险种  FROM  view_OutStaff_salaryDetail T  WHERE 1 = 1 AND T.year = ? and T.period = ?  ");
        params.add(year);
        params.add(month);
        if (null != outStaffSalaryDetail) {
            if (!StrUtil.isNullOrEmpty(outStaffSalaryDetail.getPsnName())) {
                sb.append(" AND T.psnName like ? ");
                params.add("%" + StringEscapeUtils.escapeSql(outStaffSalaryDetail.getPsnName()) + "%");
            }
            if (!StrUtil.isNullOrEmpty(outStaffSalaryDetail.getPsnCode())) {
                sb.append(" AND T.psnCode = ? ");
                params.add(outStaffSalaryDetail.getPsnCode());
            }
            if (!StrUtil.isNullOrEmpty(outStaffSalaryDetail.getPkOrg())) {
                sb.append(" AND T.pkOrg = ? ");
                params.add(outStaffSalaryDetail.getPkOrg());
            }
            if (!StrUtil.isNullOrEmpty(outStaffSalaryDetail.getPkDept())) {
                sb.append(" AND T.pkDept = ? ");
                params.add(outStaffSalaryDetail.getPkDept());
            }
        }
        if (!"区本部".equals(orgName)) {
            sb.append(" AND T.orgName LIKE ? ");
            params.add("%" + StringEscapeUtils.escapeSql(orgName) + "%");
        }
        return this.getJdbcTemplate().queryForList(sb.toString(), params.toArray());
    }
    
}
